package pacBioSimple;

import java.util.BitSet;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class MappingObject {

	private Map<Integer, BitSet> mapping_result=null;
	private int beginPosition=0;
	private int endPosition=0;
	private int seqID=0;
	
	
	public Map<Integer, BitSet> getMapping_result() {
		return mapping_result;
	}

	public void setMapping_result(Map<Integer, BitSet> mapping_result) {
		this.mapping_result = mapping_result;
	}

	public int getBeginPosition() {
		return beginPosition;
	}

	public void setBeginPosition(int beginPosition) {
		this.beginPosition = beginPosition;
	}

	public int getEndPosition() {
		return endPosition;
	}

	public void setEndPosition(int endPosition) {
		this.endPosition = endPosition;
	}

	public int getSeqID() {
		return seqID;
	}

	public void setSeqID(int seqID) {
		this.seqID = seqID;
	}

	public MappingObject()
	{
		
	}
	
	public void extractMapping(String line)
	{
		mapping_result=new HashMap<Integer, BitSet>();
		StringTokenizer st = new StringTokenizer(line," ");
		seqID = Integer.valueOf(st.nextToken()); //seq name
		beginPosition=Integer.valueOf(st.nextToken()); // position
		String mapping = st.nextToken(); //mapping result
		
		st.nextToken();
		st.nextToken();
		st.nextToken();
		st.nextToken();
		int kmerLength=Integer.valueOf(st.nextToken());
		endPosition= beginPosition+kmerLength;
				
		int i=0;
		int counter=0;
		while(i<mapping.length())
		{
			if(mapping.charAt(i)=='[')
			{
				StringBuilder sb = new StringBuilder();
				sb.append(mapping.charAt(i+1));
				sb.append(mapping.charAt(i+2));
				++i;
				++i;
				++i;
				BitSet bitSet = new BitSet();
				mapping_result.put(beginPosition+counter, MyUtil.convertStringToBit(sb.toString(), bitSet));
				++counter;
			}
			else
			{
				++counter;
			}
				++i;
		}
	}
	
	
}
